local jijing = fk.CreateSkill{
    name = "lingling__jijing",
}
Fk:loadTranslationTable{
    ["lingling__jijing"] = "机警",
    [":lingling__jijing"] = "当其他角色使用牌指定你为唯一目标时，你可以弃置一张花色相同的牌取消之，若类型也相同，你摸一张牌。",
}

jijing:addEffect(fk.TargetConfirming, {
    mute = true,
    can_trigger = function(self, event, target, player, data)
        return target == player and player:hasSkill(jijing.name) and data:isOnlyTarget(player) and data.card:getSuitString() ~= "nosuit" and data.from ~= player
    end,
    on_cost = function (self, event, target, player, data)
        local suit = data.card:getSuitString()
        local cards = player.room:askToDiscard(player,{
            skill_name = jijing.name,
            skip = true,
            pattern = ".|.|"..suit,
            cancelable = true,
            max_num = 1,
            min_num = 1,
            prompt = "机警：你可以弃置一张%arg牌令 %arg2对你无效:::"..data.card:getSuitString(true)..":"..data.card:toLogString(),
            include_equip = true,
        })
        if #cards > 0 then
            event:setCostData(self, {cards = cards})
            return true
        end
    end,
    on_use = function (self, event, target, player, data)
        local room = player.room
        local card = Fk:getCardById(event:getCostData(self).cards[1])
        room:throwCard(card, jijing.name, player)
        data:cancelTarget(data.to)

        if card.type == data.card.type then
            player:drawCards(1, jijing.name)
        end
    end,
})

return jijing